<template>
  <view class="loginConrainer">
    <image class="logo"
           src="../../images/tab4.png"></image>
    <p class="text">安心食品，您的最优选择</p>
    <div class="loginMethods">
      <button class="login wexchatLogin" @click="login">微信登录</button>
      <button class="login emailLogin">邮箱登录</button>
    </div>
  </view>
</template>

<script>
export default {
  data() {
    return {
			userInfo:{}//用户信息对象
		}
  },
  methods: {
		//登录
		login(){
			wx.getUserProfile({
				desc:'获取用户信息',
				success: (res) => {
					const {rawData ,signature} = res
					const uesrInfo = {
						rawData,signature
					}
					//缓存到本地
					wx.setStorageSync('userInfo',JSON.stringify(uesrInfo))
					//路由跳转同时传参
					wx.reLaunch({
						url:'../personal/personal?userInfo='+JSON.stringify(uesrInfo)
					})
				},
				fail:error=>{
					console.log("用户授权失败",error)
				}
			})
		}
	},
}
</script>

<style>
	.loginConrainer{
		width: 100%;
		height: 100%;
		background-color: #F8F8F8;
		display:flex;
		align-items: center;
		flex-direction: column;
	}
	.logo{
		width: 300upx;
		height: 100upx;
		margin-top: 200upx;
	}
	.text{
		font-size: 26upx;
		color: #666;
	}
	.loginMethods{
		width: 80%;
		margin: 150upx auto;
		display: flex;
		justify-content: space-around;
		
	}
.login{
	width: 240upx;
	height: 80upx;
	background: #41A863;
	color: #FFFFFF;
	text-align: center;
	line-height: 80upx;
	font-size: 26upx;
}
</style>
